﻿@page
@model GoodToCode.Entity.Event.IndexModel

@using GoodToCode.Entity.Event;

@{
    ViewData["Title"] = "Index";
}

<h1>Index</h1>

<p>
    <a asp-page="Create">Create New</a>
</p>

<form method="post">
    <div asp-validation-summary="ModelOnly" class="text-danger"></div>
    <div class="form-group">
        <label asp-for="Criteria.Name" class="control-label"></label>
        <input asp-for="Criteria.Name" class="form-control" />
        <span asp-validation-for="Criteria.Name" class="text-danger"></span>
    </div>
    <div class="form-group">
        <label asp-for="Criteria.Description" class="control-label"></label>
        <input asp-for="Criteria.Description" class="form-control" />
        <span asp-validation-for="Criteria.Description" class="text-danger"></span>
    </div>
    <div class="form-group">
        <label asp-for="Criteria.Slogan" class="control-label"></label>
        <input asp-for="Criteria.Slogan" class="form-control" />
        <span asp-validation-for="Criteria.Slogan" class="text-danger"></span>
    </div>
    <div class="form-group">
        <input type="submit" value="Search" class="btn btn-primary" />
    </div>
</form>
<div class="row">
    <div class="col-xs-offset-1 col-xs-10 ">
        @if (!ViewData.ModelState.IsValid)
        {
            @Html.ValidationSummary(false, "Action resulted in...", new { @class = "text-danger" })
        }
        else
        {
            <p class="text-info">@TempData[IndexModel.ResultMessage]</p>
        }
    </div>
</div>
@if (Model.Results?.Count > 0)
{
    <table class="table">
        <thead>
            <tr>
                <th>
                    @Html.DisplayNameFor(model => model.Results[0].Name)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.Results[0].Key)
                </th>
                <th></th>
            </tr>
        </thead>
        <tbody>
            @foreach (var item in Model.Results)
            {
                <tr>
                    <td>
                        @Html.DisplayFor(modelItem => item.Name)
                    </td>                   
                    <td>
                        @Html.DisplayFor(modelItem => item.Key)
                    </td>
                    <td>
                        <a asp-page="./Update" asp-route-id="@item.Key">Edit</a> |
                        @*<a asp-page="./Details" asp-route-id="@item.Key">Details</a> |*@
                        <a asp-page="./Delete" asp-route-id="@item.Key">Delete</a>
                    </td>
                </tr>
            }
        </tbody>
    </table>
}